IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spUsers_Create')
	BEGIN
		PRINT 'Dropping Procedure spUsers_Create'
		DROP  Procedure  spUsers_Create
	END

GO

PRINT 'Creating Procedure spUsers_Create'
GO
CREATE Procedure dbo.spUsers_Create
	( 	  
	  @UserLogon varchar(50), 
		@UserPassword varchar(50) = null, 
		@FirstName varchar(100) = null, 
		@Surname varchar(100) = null, 
		@Extention varchar(50) = null, 
		@Telephone varchar(50) = null, 
		@Cellphone varchar(50), 
		@Email varchar(250) = null, 
		@DivisionName varchar(50) = null, 
		@DepartmentName varchar(50) = null, 
		@Access varchar(5000) = null, 
		@Active bit = null
	)
AS
  /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 2007/11/02    Initial version created
    ------------------------------------------------------------------------------
  */

	-- Declare the required variables

	-- Create the required new record
	INSERT INTO Users
	  (
		UserLogon,
			UserPassword,
			FirstName,
			Surname,
			Extention,
			Telephone,
			Cellphone,
			Email,
			DivisionName,
			DepartmentName,
			Access,
			Active	  
	  )
	VALUES
	  (
		@UserLogon,
			@UserPassword,
			@FirstName,
			@Surname,
			@Extention,
			@Telephone,
			@Cellphone,
			@Email,
			@DivisionName,
			@DepartmentName,
			@Access,
			@Active
	  )

	-- Handle any errors
	IF @@ERROR != 0
	BEGIN
		RAISERROR('spUsers_Create: Unable to Insert a new Users', 10, 1)
		RETURN
	END

	-- Return the newly created ID
	SELECT	@@IDENTITY AS 'Users_ID'

	-- Return to calling method
	RETURN 

GO
